<?php
session_start();
error_reporting(E_ALL);

//Includes
include 'php/functies.php';
include 'php/instagram.php';

//Taal instellen
if(isset($_SESSION['main'])){
	$mainarray = $_SESSION['main'];
	$taal = $mainarray['taal'];
}else{
	if(isset($_COOKIE['language'])){
		$taal = $_COOKIE['language'];
		$mainarray['taal'] = $taal;
		$_SESSION['main'] = $mainarray;
	}else{
		$taal =  getDefaultLanguage();
		$mainarray['taal'] = $taal;
		$_SESSION['main'] = $mainarray;
		$expire=time()+60*60*24*30;
		setcookie('language', $taal, $expire);
	}//if
}//if

require('language/'.$taal.'.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Mark Post</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/jquery.fancybox.css?v=2.1.3" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="js/ga.js"></script>
</head>

<body>

<header>
		<h1><a href="http://www.mark-post.nl/" title="Mark Post - Home" onclick="_gaq.push(['_trackPageview','home']);return true;">Mark Post</a></h1>
</header>

<div id="container">
	<div id="sidebar">
   
      <nav>
         <div class="button"><?php echo lang('NAV'); ?>
            <div id="navigationmenu">
               <ul id="menu">
                  <li><a href="#home" title="Home" onclick="_gaq.push(['_trackPageview','home']);return true;">Home</a></li>
                  <li><a href="#aboutme" title="Over mij" onclick="_gaq.push(['_trackPageview','aboutme']);return true;"><?php echo lang('OV'); ?></a></li>
                  <li><a href="#instagram" title="Instagram" onclick="_gaq.push(['_trackPageview','instagram']);return true;">Instagram</a></li>
                  <li><a href="#contact" title="Contact" onclick="_gaq.push(['_trackPageview','contact']);return true;">Contact</a></li>
               </ul>
               <span class="clear"></span>
            </div>
         </div>
      </nav>
   
      <div id="social">
         <a href="redirect.php?linkto=twitter" title="Twitter" onclick="_gaq.push(['_trackEvent','social','twitter']);return true;"><img src="img/social/twitter.png" alt="Twitter"></a> 
         <a href="redirect.php?linkto=instagram" title="Instagram" onclick="_gaq.push(['_trackEvent','social','instagram']);return true;"><img src="img/social/instagram.png" alt="Instagram"></a> 
         <a href="redirect.php?linkto=tumblr" title="Tumblr" onclick="_gaq.push(['_trackEvent','social','tumblr']);return true;"><img src="img/social/tumblr.png" alt="Tumblr"></a> 
         <a href="redirect.php?linkto=flickr" title="Flickr" onclick="_gaq.push(['_trackEvent','social','flickr']);return true;"><img src="img/social/flickr.png" alt="Flickr"></a><br>
         <a href="redirect.php?linkto=pinterest" title="Pinterest" onclick="_gaq.push(['_trackEvent','social','pinterest']);return true;"><img src="img/social/pinterest.png" alt="Pinterest"></a> 
         <a href="#contact" title="E-mail" onclick="_gaq.push(['_trackPageview','contact']);return true;"><img src="img/social/email.png" alt="E-mail"></a> 
         <a href="#" title="Empty"><img src="img/social/button-white.png" alt="Empty"></a> 
         <a href="#" title="Empty"><img src="img/social/button-white.png" alt="Empty"></a> 
      </div>
   </div>

   <div class="contpaper">
   	<div class="paper"></div>
      <div id="content">      
			<section class="maincontent" id="sechome">
 				<h2>Home</h2>
				<p><?php echo lang('WM'); ?></p>
			   <img class="img_home" src="img/image.jpg" alt="Afbeelding"/>
			   <p><a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mark-post.nl" title="HTML 5 Valid">HTML 5 Valid</a></p>
			  	<br/>
			   <img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width="165" height="64" alt="HTML5 Powered with CSS3 / Styling, and Semantics" title="HTML5 Powered with CSS3 / Styling, and Semantics">
			</section>
     	</div>
   </div>
</div>

<footer>&copy; 2012 Mark Post - markpost[at]mark-post.nl | 
	<a href="#home" title="Home" onclick="_gaq.push(['_trackPageview','home']);return true;">Home</a> - 
   <a href="#aboutme" title="<?php echo lang('OV'); ?>" onclick="_gaq.push(['_trackPageview','aboutme']);return true;"><?php echo lang('OV'); ?></a> - 
   <a href="#instagram" title="Instagram" onclick="_gaq.push(['_trackPageview','instagram']);return true;">Instagram</a> - 
   <a href="#contact" title="Contact" onclick="_gaq.push(['_trackPageview','contact']);return true;">Contact</a> | 
   <a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mark-post.nl" title="HTML 5 Valid" onclick="_gaq.push(['_trackEvent', 'footer','html5valid']);return true;">HTML 5 Valid</a> | 
   <img id="nl" src="img/nl.gif" alt="Nederlands"> <img id="en" src="img/gb.gif" alt="English">
</footer>

<script type="text/javascript" src="js/jquery.fancybox.pack.js?v=2.1.3"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/jquery.noty.js"></script>
<script type="text/javascript" src="js/layouts/center.js"></script>
<script type="text/javascript" src="js/themes/default.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $('.button').hover(
    function() { $('#navigationmenu').fadeIn(600); },
    function() { $('#navigationmenu').fadeOut(600); }
  );
});

$(function() {
	$('.load_more').live("click",function() {
		var ID = $(this).attr("id");
		if(ID){
			$("#load"+ID).html('<br>Loading...');

			$.ajax({
				type: "POST",
				url: "php/more_getrecent.php",
				data: "max_id="+ ID, 
				cache: false,
				success: function(html){
					$("#photos").append(html);
					// remove the previous load more link
					$("#load"+ID).remove();
				}
			});
		}else{
			// End or articles (no more)
			$(".load_more").html('');
		}

		return false;
	});
});

$(document).ready(function() {
	$(".fancybox").fancybox();
});
  
function generate(text, type) {
	var n = noty({
  		text: text,
  		type: type,
      dismissQueue: true,
  		layout: 'center',
  		theme: 'defaultTheme'
  	});
	console.log('html: '+n.options.id);
}

$(document).ready(function() {
   $("footer img").click(function(e) {
		var ID = $(this).attr("id");
		$.ajax({
				type: "GET",
				url: "php/setcookie.php",
				data: "language="+ ID, 
				cache: false,
				success: function(html){
					location.reload();
				}
		});
	});
});
</script>
<?php
preg_match('@^(?:http://)?([^/]+)@i', $_SERVER['HTTP_REFERER'], $matches);
$host = $matches[1];
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
switch($matches[0]){
	case 'facebook.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','facebook']);</script><?php
		break;
	case 'twitter.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','twitter']);</script><?php
		break;
	case 'pinterest.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','pinterest']);</script><?php
		break;
	case 'tumblr.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','tumblr']);</script><?php
		break;
	case 'flickr.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','flickr']);</script><?php
		break;
	case 'instagram.com':
		?><script type="text/javascript">_gaq.push(['_trackEvent','source','instagram']);</script><?php
		break;	
}//switch
?>

</body>
</html>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
	if(isset($_POST)){
		if(sendemail()){
			?>
<script type="text/javascript">
	$(document).ready(function() {
		generate('<?php echo lang('sendsuccess'); ?>', 'success');
	});
</script>
      	<?php
		}else{
			?>
<script type="text/javascript">
	$(document).ready(function() {
		generate('<?php echo lang('senderror'); ?>', 'warning');
	});
</script>
      	<?php
		}//if
	}//if
}//if

session_destroy();
?>